<section class="vbox">
	<section class="scrollable padder">
		<div class="m-b-md">
			<h3 class="m-b-none">项目配置</h3>
		</div>
		<form class="form-horizontal form-pajax form-validate" method="post"  action="<?php echo \Yii::$app->urlManager->createUrl("project/create"); ?>">
			<div class="row">
				<div class="col-sm-12">
					<section class="panel panel-default">
						<header class="panel-heading font-bold">
							基本配置
						</header>
						<div class="panel-body">
								<div class="form-group">
									<label class="col-sm-2 control-label">项目名</label>
									<div class="col-sm-10 controls">
										<input type="text" class="form-control rounded" name="project_name" data-rule-required="true">
									</div>
								</div>
								<div class="line line-dashed b-b line-lg pull-in"></div>
								<div class="form-group">
									<label class="col-sm-2 control-label">项目环境</label>
									<div class="col-sm-10">
										<select name="project_env" class="form-control m-b" data-rule-required="true">
											<option value="1">测试环境</option>
											<option value="2">预发布环境</option>
											<option value="3">线上环境</option>
										</select>
									</div>
								</div>
						</div>
					</section>
				</div>
				<div class="col-sm-4">
					<section class="panel panel-default">
						<header class="panel-heading font-bold">宿主机</header>
						<div class="panel-body">
								<div class="form-group">
									<label class="col-lg-2 control-label">代码检出仓库</label>
									<div class="col-lg-10 controls">
										<input type="text" class="form-control" name="deploy_from" placeholder="/data/www/application" data-placement="top" data-toggle="tooltip" title="代码的检出存放路径" data-rule-required="true">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">排除文件</label>
									<div class="col-lg-10">
										<textarea type="text" name="deploy_skip_file" class="form-control" placeholder=".git
.svn
README.md" rows="10" data-placement="top" title="剔除不上线的文件、目录，每行一个" data-toggle="tooltip"></textarea>
									</div>
								</div>
						</div>
					</section>
				</div>
				<div class="col-sm-4">
					<section class="panel panel-default">
						<header class="panel-heading font-bold">目标机器</header>
						<div class="panel-body">
								<div class="form-group">
									<label class="col-lg-2 control-label">用户</label>
									<div class="col-lg-10 controls">
										<input type="text" class="form-control" name="release_user" placeholder="www" data-placement="top" data-toggle="tooltip" title="代码的部署的用户，一般是运行的服务的用户，如php进程用户www" data-rule-required="true">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">webroot</label>
									<div class="col-lg-10 controls">
										<input type="text" class="form-control" name="release_webroot" placeholder="/data/www/application" data-toggle="tooltip" data-placement="top" title="代码的最终部署路径，请不要在目标机新建此目录，walle会自动生成此软链，正确设置父目级录即可" data-rule-required="true">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">发布版本库</label>
									<div class="col-lg-10 controls">
										<input type="text" class="form-control" placeholder="/data/releases" data-toggle="tooltip" name="release_version" data-placement="top" title="代码发布的版本库，每次发布更新webroot的软链到当前最新版本" data-rule-required="true">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">版本保留数</label>
									<div class="col-lg-10">
										<input type="text" class="form-control" placeholder="20" name="skip_version_num" data-toggle="tooltip" title="过多的历史版本将被删除，只可回滚保留的版本">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">机器列表</label>
									<div class="col-lg-10 controls">
										<textarea name="release_hosts" class="form-control" placeholder="192.168.0.1
192.168.0.2:8888" rows="5" data-placement="top" title="要发布的机器列表，一行一个，非22端口可 ip:port" data-toggle="tooltip" data-rule-required="true"></textarea>
									</div>
								</div>
						</div>
					</section>
				</div>
				<div class="col-sm-4">
					<section class="panel panel-default">
						<header class="panel-heading font-bold">高级任务</header>
						<div class="panel-body">
								<div class="form-group">
									<label class="col-lg-2 control-label">pre_deploy</label>

									<div class="col-lg-10">
										<input type="text" name="pre_deploy" class="form-control" placeholder="" data-placement="top" title="在部署代码之前的准备工作，如git的一些前置检查、vendor的安装（更新），一行一条" data-toggle="tooltip">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">post_deploy</label>
									<div class="col-lg-10">
										<input type="text" name="post_deploy" class="form-control" placeholder="" data-placement="top" data-toggle="tooltip" title="git代码检出之后，可能做一些调整处理，如vendor拷贝，环境适配（mv config-test.php config.php），一行一条">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">pre_release</label>
									<div class="col-lg-10">
										<input type="text" name="pre_release" class="form-control" placeholder="" data-placement="top" data-toggle="tooltip" title="同步完所有目标机器之后，更改版本软链之前触发任务。java可能要做一些暂停服务的操作(双引号将会被转义为\")">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">post_release</label>
									<div class="col-lg-10">
										<input type="text" name="post_release" class="form-control" placeholder="" data-placement="top" data-toggle="tooltip" title="所有目标机器都部署完毕之后，做一些清理工作，如删除缓存、平滑重载/重启服务（nginx、php、task），一行一条(双引号将会被转义为\")">
									</div>
								</div>
								<div class="form-group">
									<label class="col-lg-2 control-label">post_release_delay</label>
									<div class="col-lg-10">

										<input type="text" class="form-control" placeholder="0" title="按顺序在每台目标机执行高级任务，每台服务器执行完毕后暂停x秒。
			默认设置为 0，应用服务使用平滑重载，仅当应用服务无法支持平滑重载必须重启时才配置此参数。
			设置为大于 0 的值会出现代码发布阶段各个服务器业务代码逻辑不一致的情况，请谨慎配置" data-placement="top" data-toggle="tooltip" value="0">
									</div>
								</div>
						</div>
					</section>
				</div>
			</div>
			<section class="panel panel-default">
				<header class="panel-heading text-right bg-light">
					<ul class="nav nav-tabs pull-left">
						<li class="active" id="show-git"><a href="#messages-2" data-toggle="tab"><i class="fa fa-github text-muted"></i> Git</a></li>
						<li id="show-svn"><a href="#profile-2" data-toggle="tab"><i class="fa iconfont icon-svn text-muted"></i> Svn</a></li>
					</ul>
					<span class="hidden-sm">代码仓库</span>
					<input type="hidden" name="repo_type" value="git" id="repo_type">
				</header>
				<div class="panel-body">
					<div class="tab-content">
						<div class="tab-pane fade active in" id="messages-2">
							<div class="form-group">

								<div class="col-lg-12 controls">
									<label>地址</label>
									<input type="text" name="git"  data-rule-required="true" class="form-control" placeholder="git@gitee.com:huicms/application.git">
								</div>
							</div>
						</div>
						<div class="tab-pane fade " id="profile-2">
							<div class="form-group">

								<div class="col-lg-12 controls">
									<label>地址</label>
									<input type="text" class="form-control" name="svn" data-rule-required="true" placeholder="https://gitee.com/huicms/application.git">
								</div>
							</div>
							<div class="form-group pull-in clearfix">
								<div class="col-sm-6">
									<label>用户名</label>
									<input type="text" name="svn_username" class="form-control">
								</div>
								<div class="col-sm-6">
									<label>密码</label>
									<input type="password" name="svn_password" class="form-control">
								</div>
							</div>
						</div>
					</div>
				</div>
			</section>

			<section class="panel panel-default">
				<header class="panel-heading font-bold">
					基本配置
				</header>
				<div class="panel-body">
						<div class="form-group">
							<label class="col-sm-2 control-label">分支/tag上线</label>
							<div class="col-sm-10">
								<label class="checkbox-inline i-checks">
									<input type="radio" value="branch" name="repo_mode" checked>
									<i></i>
									branch
								</label>
								<label class="checkbox-inline i-checks">
									<input type="radio" value="tag" name="repo_mode">
									<i></i>
									tag
								</label>
							</div>
						</div>
						<div class="line line-dashed b-b line-lg pull-in"></div>
						<div class="form-group">
							<label class="col-sm-2 control-label"><a data-placement="top" data-toggle="tooltip" title="开启时，用户提交上线任务需要审核方可上线">是否开启审核</a></label>
							<div class="col-sm-10">
								<label class="switch">
									<input type="checkbox" class="" name="repo_audit" value="1">
									<span></span>
								</label>
							</div>
						</div>
						<div class="line line-dashed b-b line-lg pull-in"></div>
						<div class="form-group">
							<label class="col-sm-2 control-label"><a data-placement="top" data-toggle="tooltip" title="开启时，通过Ansible并发传输文件，加快多机器时的代码发布速度。需安装 ansible，详见文档">是否开启Ansible</a></label>
							<div class="col-sm-10">
								<label class="switch">
									<input type="checkbox" name="repo_ansible" value="1">
									<span></span>
								</label>
							</div>
						</div>
						<div class="line line-dashed b-b line-lg pull-in"></div>
						<div class="form-group">
							<label class="col-sm-2 control-label"><a data-placement="top" data-toggle="tooltip" title="若关闭,则将无法发布上线">是否启用</a></label>
							<div class="col-sm-10">
								<label class="switch">
									<input type="checkbox" name="status" value="1">
									<span></span>
								</label>
							</div>
						</div>

						<div class="line line-dashed b-b line-lg pull-in"></div>
						<div class="form-group">
							<div class="col-sm-4 col-sm-offset-2">
								<button type="reset" class="btn btn-default">取消</button>
								<button type="submit" class="btn btn-primary">提交</button>
							</div>
						</div>
				</div>
			</section>
		</form>
	</section>
</section>
<script>
	$(document).ready(function() {
		$('#show-git').click(function() {
			$('#repo_type').val('git');
		});
		$('#show-svn').click(function() {
			$('#repo_type').val('svn');
		});
	});
</script>